local Entity = require "entitybase.Entity"

local tbname = 'fwqp_stock'
local TB = class(tbname, Entity)

function TB:ctor(operate)
	TB.super.ctor(self)
	self.tbname = tbname
	self.operate = operate
	self.msg = operate.msg
	--注册消息
	self:register()
end

function TB:register()
	self.msg:registerSelf('add_stock',handler(self,self.addStock))
	self.msg:registerSelf('get_stock',handler(self,self.getStock))	
	self.msg:registerSelf('delete_stock',handler(self,self.deleteStock))
	self.msg:registerSelf('update_stock',handler(self,self.updateStock))	
	self.msg:registerSelf('save_stock',handler(self,self.saveStock))
	self.msg:registerSelf('reload_stock',handler(self,self.reload))
	self.msg:registerSelf('unload_stock',handler(self,self.unload))	
end

function TB:addStock(row)
	--print("______________getStock___")
	return self:add(row)
end

function TB:deleteStock(row)
	return self:delete(row)
end

function TB:getStock(gameid)
	return self:get(gameid)
end

function TB:updateStock(row)
	return self:update(row)
end

function TB:saveStock(row)
	if not row.gameid then 
		return
	end
	if self:get(row.gameid) then 
		self:update(row)
	else
		self:add(row)
	end
end



return TB
